package cn.stylefeng.guns.sys.modular.system.service;

import cn.hutool.core.lang.UUID;
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.sys.modular.system.entity.KmsApp;
import cn.stylefeng.guns.sys.modular.system.mapper.KmsAppMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author YuJiBiao
 * @version: 1.0
 * @Date 2020/7/8 16:54
 **/
@Service
public class KmsAppService extends ServiceImpl<KmsAppMapper, KmsApp> {

    /**
     * 根据条件查询App列表
     *
     * @author fengshuonan
     * @Date 2018/12/24 22:45
     */
    public Page<Map<String, Object>> selectKmsApp() {
        Page page = LayuiPageFactory.defaultPage();
        return this.baseMapper.selectKmsApp(page);
    }


    /**
     *
     * @param name
     */
    public void add(String name) {
        KmsApp kmsApp = new KmsApp();
        kmsApp.setName(name);
        kmsApp.setStatus(1);
        kmsApp.setToken(UUID.randomUUID().toString());
        kmsApp.setCreateTime(new Date());
        this.save(kmsApp);
    }

    public List<KmsApp> getAll() {
        return this.baseMapper.getAll();
    }
}
